import global from "../../global";
import Player from "../battle/player";
import PlayerMessage from "./playerMessage";

const {ccclass, property} = cc._decorator;

@ccclass
export default class OtherPlayers extends cc.Component {

    @property(cc.Node)
    Others:cc.Node = null;      //节点，里面再放玩家信息
    @property(cc.Prefab)    
    Prefab_playerMessage:cc.Prefab = null;  //玩家信息


    /**
     * 有玩家信息要放进来了
     */
    addPlayer(player:Player){
        let node = cc.instantiate(this.Prefab_playerMessage);
        this.Others.addChild(node);
        node.getComponent(PlayerMessage).init(player);
    }

    /**
     * 开启或者关闭玩家信息
     */
    openOrClose(){
        if(this.Others.active){
            this.Others.active = false;
        }else{
            this.Others.active = true;
        }
    }
    
}
